package com.itheima.d1_polymorphism;

/*
    目标：掌握使用多态的好处，以及多态下的类型转换问题。
 */
public class Test2 {

    public static void main(String[] args) {
        Student student = new Student();
        tesrRun(student);
        Teacher teacher = new Teacher();
        tesrRun(teacher);
    }

    public static void tesrRun(People p) {
        if (p instanceof Student) {
            System.out.println("开始跑步，计时开始");
            p.run();
            Student s = new Student();
            s.eat();
            System.out.println("跑步结束");
        }
        if (p instanceof Teacher) {
        System.out.println("---------------------------");
            System.out.println("开始跑步，计时开始");
            p.run();
            Teacher t = new Teacher();
            t.sing();
            System.out.println("跑步结束");
        }
    }

}
